home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PRINTER
/
PROHP.ARJ
/
DLPI.PRG
< prev
next >
Wrap
Text File
|
1992-06-23
|
4KB
|
123 lines
/*
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ Program : lpi.PRG │
│ │
│ Purpose : demonstrate the use of HP_lpi() using SIZEBYROWCOL. │
│ │
│ Author : Copyright (C) 1992, I.L.A.,Inc. All Rights reserved. │
│ │
│ Comments: This source code may be distributed and used freely │
│ provided that the copyright notice is not removed. │
│ │
└─────────────────────────────────────────────────────────────────────────┘
*/
#include "prohp.ch"
proc main()
Local cTestLine := "Text Line in Box.",i,nHeight
Local nBoxH:=4,nBoxW:=3, nLm := 0.2
Local nTop:=0.3, nLeft1:=0.3,nLeft2:=nBoxW+0.5
Local cText,nColW,nLc
set2print("dlpi.hpc")
HP_init()
HP_send(.t.)
HP_pitch(10) // courier 10
HP_lpi(6) // 6 LPI
HPshadow(.t.) // shadow boxes is nicer
HP_box(nTop,nLeft1,nBoxH,nBoxW) // draw box 1
HP_box(nTop,nLeft2,nBoxH,nBoxW) // draw box 2
HP_setpos(nTop,nLeft1) // absolute cursor position to box 1
prbox(nBoxH,nLeft1+nLm) // Print at all line in box
HP_setpos(nTop,nLeft2) // absolute cursor position to box 2
HP_pitch(16) // courier 16
HP_lpi(10) // set 10 LPI
// Print at all line in box and set the proper left margin
prbox(nBoxH,nLeft2+nLm)
nTop+= nBoxH +0.5
nBoxH /= 2
//nBoxW /= 2
HP_box(nTop,nLeft1,nBoxH,nBoxW) // draw box
HP_pitch(10)
cText := "If the human race wishes to have a prolonged and "+;
"indefinite period of material prosperity, they have only got to "+;
"behave in a peaceful and helpful way toward one another, and "+;
"science will do for them all they wish and more than they can "+;
"dream. "+chr(13)+chr(10)+" -Winston Churchill"
// find how many columns in nBoxW
nColW := HPi2col(nBoxW-nLm) // * HP_data(D_CPI)
// Find how many lines in cText
nLc:= mlcount(cText,nColW)
// Set LPI to fit the entire box height - bottom margin of 0.1"
HP_lpi(nLc /(nBoxH-0.1))
// print the text in box
HP_setpos(nTop,nLeft1+nLm)
for i:=1 to nLc
HP_rcpos(1,,.t.) // one line down
HP_setpos(,nLeft1+nLm) // move to left margin
qqout(memoline(cText,nColW,i))
next
/*
now we will fit the box size to the text set Width and Height
will be calculating according to the current LPI
*/
HP_pitch(16)
// find how many columns in nBoxW
nColW := HPi2col(nBoxW-nLm) // * HP_data(D_CPI)
// Find how many lines in cText
nLc:= mlcount(cText,nColW)
/*
change the next LPI setting to see how the following
code will adjust itself to the new setting.
*/
HP_lpi(8)
// Set nBoxH to hold all lines of text
nBoxH := HProw2i(nLc)+0.1 // add 0.1" for bottom margin
// draw filled box as background to the text
HPsetshadow(,GFILLBLACK) // make dark shadow
HP_fillbox(nTop,nLeft2,nBoxH,nBoxW,,GFILLGRAY,10)
HP_setpos(nTop,nLeft2+nLm)
for i:=1 to nLc
HP_rcpos(1,,.t.) // one line down
HP_setpos(,nLeft2+nLm) // move to left margin
qqout(memoline(cText,nColW,i)) // print the line
next
/*
Now we leave you with the chalange to find the Width of a box
to hold cText when you have LPI and Height .
*/
HP_reset()
set2screen()
return
proc Prbox(nHeight,nLeftMargin)
Local cTestLine:="And The Oscar Goes to ",i
HP_savecsr()
// draw separation lines
For i:=1 to nHeight*HP_data(D_LPI)
HP_rcpos(1,,.t.) // move one line down
HP_setpos(,nLeftMargin)
HP_rline(0.01,HPstsize(cTestLine+str(i,2)),GFILLGRAY,60)
next
HP_restcsr()
// print text in box
For i:=1 to nHeight*HP_data(D_LPI) -1
HP_rcpos(1,,.t.) // move one line down
HP_setpos(,nLeftMargin) // move to left margin
qqout(str(i,2),cTestLine) // print string
next
return